package com.example.work05;
import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.widget.RadioGroup;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    RadioGroup rg;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        rg= findViewById(R.id.radioGroup);
        rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                String str = null;
                switch (i){
                    case R.id.radioButton1:
                        str="您选择的是春";
                        break;
                    case R.id.radioButton2:
                        str="您选择的是夏";
                        break;
                    case R.id.radioButton3:
                        str="您选择的是秋";
                        break;
                    case R.id.radioButton4:
                        str="您选择的是冬";
                        break;
                }
                Toast.makeText(MainActivity.this,str,Toast.LENGTH_LONG).show();
            }
        });
    }
}